﻿//jQuery.noConflict();
_addColor = function(i,c){
	i = i && i[1] && +i[1];
	return ["#ccc","#555","#ccc","#E0CA74"][i] || c;
}(/\bs=(\d+)\b/.exec(location.search),_addColor);
var wall = {
	_time:0,
	_last:null,
	_nextgetTime:2000,
	isInFrame:function(){
		/*
		if (wall._isInFrame){
			return true;
		}
		try{
			if(parent.location.hostname === undefined){
				wall._isInFrame = true;
				return true;
			};
		}catch(e){
			wall._isInFrame = true;
			return true;
		}
		return false;
		*/
		return window !== parent;
	},
	isTencent:function(){
		var host = /^https?:\/\/([0-9a-zA-Z\-\.]+)(?::\d+)?\//.exec(document.referrer),
			hostname = host && host[1];
		if (hostname && (/^(?:[0-9a-zA-Z\-]+\.)*(qq|paipai|qzone|3366|gtimg|openmat|yixun|myapp|wanggou|51buy)\.com$/.test(hostname))){
			return true;
		}
		return false;
	},
	getNextTimer:function(){
		if (wall._nextgetTime>300000){
			wall._nextgetTime = 300000;
		}else if(wall._nextgetTime<2000){
			wall._nextgetTime = 2000;
		}
		return wall._nextgetTime;
	},
	list:[],
	userlist:{},//被提到的用户列表
	emos:"惊讶,撇嘴,色,发呆,得意,流泪,害羞,闭嘴,睡,大哭,尴尬,发怒,调皮,呲牙,微笑,难过,酷,非典,抓狂,吐,偷笑,可爱,白眼,傲慢,饥饿,困,惊恐,流汗,憨笑,大兵,奋斗,咒骂,疑问,嘘...,晕,折磨,衰,骷髅,敲打,再见,闪人,发抖,爱情,跳跳,找,美眉,猪头,小狗,钱,拥抱,灯泡,酒杯,音乐,蛋糕,闪电,炸弹,刀,足球,猫咪,便便,咖啡,饭,女,玫瑰,凋谢,男,爱心,心碎,药丸,礼物,吻,会议,电话,时间,太阳,月亮,强,弱,握手,胜利,邮件,电视,多多,美女,汉良,飞吻,怄火,毛毛,Q仔,西瓜,多云,转晴,雪人,星星,女人,男人,冷汗,擦汗,抠鼻,鼓掌,糗大了,坏笑,左哼哼,右哼哼,哈欠,鄙视,委屈,快哭了,阴险,亲亲,吓,可怜,菜刀,啤酒,篮球,乒乓,示爱,瓢虫,抱拳,勾引,拳头,差劲,爱你,NO,OK,转圈,磕头,回头,跳绳,挥手,激动,街舞,献吻,左太极,右太极,黑丝带,祈福,黄丝带,百合花,红包,喜糖,月饼,酒,团圆饼,玉兔,蛋黄月饼,灯笼,红旗,日历,七休哥,万圣节".split(","),
	temp:'\
	<li class="weibo_li">\
		<div class="weibo_head">\
			<a href="http://t.qq.com/<%=data.name%>?pref=internal" target="_blank" title="<%=data.nick%>">\
				<img src="<%=act.showHead(data.head)%>" class="weibo_head_img" alt="<%=data.nick%>"/>\
			</a>\
		</div>\
		<div class="weibo_info">\
			<a href="http://t.qq.com/<%=data.name%>?pref=internal" target="_blank" class="weibo_nick"><%=data.nick%></a>\
			<%=getVipIconStr(data.isvip)%><%=getTypeStr(data.type)%><%=getWeiboText(data.status,data.text)%>\
			<%=getSourceStr(data.source)%>\
			<%=getImgs(data.image,data.id)%>\
			<%=getVideo(data.video,data.id)%>\
			<div class="weibo_time"><a href="http://t.qq.com/p/t/<%=data.id%>" target="_blank"><%=getTime(data.timestamp)%></a></div>\
		</div>\
	</li>',
	tempSource:'<div class="weibo_source">\
		<a href="http://t.qq.com/<%=data.name%>?pref=internal" target="_blank" class="weibo_nick"><%=data.nick %></a>\
		<%=getVipIconStr(data.isvip) %><%=getTypeStr(data.type)%><%=getWeiboText(data.status,data.text) %>\
		<%=getImgs(data.image,data.id)%>\
		<%=getVideo(data.video,data.id)%>\
		<div class="weibo_time"><a href="http://t.qq.com/p/t/<%=data.id%>" target="_blank"><%=getTime(data.timestamp)%></a></div>\
	</div>',
	area:$('#htArea'),
	init:function(){
		(function(){
			var timer = 0,setHeight = function(){wall.area.height($("body").height()-$("#postArea").size() * ($("#postArea").height()+14)-$("#header").height());};
			if ($("body").height()>0){
				setHeight();
			}else{
				var timer = setInterval(function(){
					if ($("body").height()>0){
						clearInterval(timer);
					}
				},100);
			}
		})();
		wall.getToken();
		wall.get();
		wall.followUser();
		wall.setFastKey();
		
		$("#postForm").submit(function(){
			var val = $("#content").val(),arr = [val],hts = val.match(/#([^#]{1,20})#/g);
			if ($("#post").hasClass("disabled")){
				return false
			}
			if (hts && hts.length>2){
				wall.showErr('一条广播中最多包含两个话题',1,1);
				return false;
			}
			if (/^(\s*#[^#]{1,20}#\s*)*$/.test(val)){
				wall.showErr('再说点什么吧',1,1);
				return false;
			}
			if (wall.weiboContent.getContentLen()<0){
				arr[0] = wall.weiboContent.smartCut(val,140);
			}
			if (window._hadlogin === 1){
				wall.showErr("发表中",2,1);
				if (window._url){
					arr.push("( 来自"+window._url+" )");
				}
				$("#post").addClass("disabled");
				$("#content2").val(arr.join(" "));
				//return false;
				if (($("#selectFile").val())){
					$("#fileStatus").removeAttr("class").addClass("loading").html("上传中");
				}else{
					$("#fileStatus").removeAttr("class").html("图片");
				}
				return true;
			}else if(window._hadlogin === -1){
				wall.showErr('您还没有开通微博, <a href="http://reg.t.qq.com/invite/" target="_blank">点此开通微博</a>',1,1);
				return false;
			}else{
				wall.showErr('您还未登录，<a href="javascript:;" onclick="wall.showLoginWin(1);">请先登录</a>！',1,1);
				wall.showLoginWin(1);
				return false;
			}
		});
		
		$("#btnScroller").click(function(){
			wall.appOne();
		});
		
		$("#selectFile").change(function(){
			$("#fileStatus").removeAttr("class").addClass("success").html("已选择图片");
		});
		
		$('#content').keyup(function(event){
			var l = wall.weiboContent.getContentLen();
			if(l<0){
				$('#content').addClass('notinput');
				wall.showErr(l,1);
			}else{
				$('#content').removeClass('notinput');
				$('#eMsg').html(l);
				wall.showErr(l,0);
			}
		}).trigger("keyup");
		
		if (!_scrollFlag){
			$("#htArea").bind("mousewheel",function(event){
				var k = event.wheelDelta? event.wheelDelta:-event.detail*10;
					this.scrollTop = this.scrollTop - k;
					return false;
			});
		}else{
			$("#btn_weibo_next").click(function(){
				$(this).addClass("loading").find(".btn_weibo_next_text").html("正在加载");
				wall.get();
			});
		}
	},
	pushData:function(d,call){
		var users = d && d.user,info = d.info;
		if (users){
			for(var n in users){
				if (users[n]!=""){
					wall.userlist[n] = users[n];
				}
			}
		}
		
		if(typeof call == 'function'){
			var w = wall.weibo();
				w.getTime();
				
			if (_scrollFlag){
				call(info);
				wall.infoext = d.infoext;
			}else{
				if (wall._last){
					info = d.info.sort(function(v1,v2){
						return v1.timestamp-v2.timestamp;
					});
				}
				for(var i=0,k=info.length;i<k;i++){
					var df = info[i];
					if (wall._last && wall._last.timestamp && wall._last.timestamp >= df.timestamp){
						break;
					}
					if (wall.list.length){
						for(var j=0,jk=wall.list.length;j<jk;j++){
							if (df.timestamp === wall.list[j].timestamp){
								break;
							}
						}
					}
					wall.list.push(df);			
				}
				var v2= wall.list.slice(-1)[0],v1 = wall.list.slice(0,1)[0];
				if (wall.list.length){
					wall._last = wall.list.slice(0,1)[0];
					call();
					wall._nextgetTime /= 2;
				}else{
					wall._nextgetTime *= 2;
					setTimeout(wall.get,wall.getNextTimer());
				}
			}
		}
	},
	get:function(){
		var _url = _appurl + '/index.php?c=wall&a=topic&ak='+_appkey+'&t='+_htname+'&fk='+_klist+'&fn='+_nlist+'&rnd='+(+new Date());
		if (_scrollFlag && wall.infoext){
			_url += "&topic="+encodeURIComponent(wall.infoext.topic)+"&tid="+wall.infoext.tid+"&time="+wall.infoext.time;
		}
		$.ajax({
			url: _url,
			dataType: "json",
			success: function (d) {
				var ret = +(d && d.ret),data = d && d.data;
		    	if(ret === 0){
					if (data) {
						if (_scrollFlag) {
							if ((!data.info && $("#msgArea").find(".errorMsg").size())) {
								$("#btn_weibo_next").remove();
							} else {
								if (data && data.hasnext === 0) {
									$("#btn_weibo_next").remove();
								} else {
									$("#btn_weibo_next").removeClass("loading").find(".btn_weibo_next_text").html("查看更多");
								}
								wall.pushData(data, wall.callWithScroller);
							}
						} else {
							wall.pushData(data, wall._last && wall.appOne || wall.callWithNoScroller);
						}
					} else {
						//$("#btn_weibo_next").addClass("none");
					}	
		    	}else{
		    		
		    		if(wall.list.length==0){
		    		switch(data && data.info && data.info[0]){
		    			case 2:
		    				$('#msgArea').html('<li><div class="errorMsg" style="width:100%;height:100%"><div style="width:160px;height:75px;margin:0 auto;"></div><div style="padding:30px;text-align:center;">错误码'+parseInt(data.info[0])+'您的访问频率太快拉</div></div></li>');
		    				break;
		    			case 9:
		    				$('#msgArea').html('<li><div class="errorMsg" style="width:100%;height:100%"><div style="width:160px;height:75px;margin:0 auto;"></div><div style="padding:30px;text-align:center;">错误码'+parseInt(data.info[0])+'该话题下还没有消息</div></div></li>');
		    				break;
		    			case 7:
		    				$('#msgArea').html('<li><div class="errorMsg" style="width:100%;height:100%"><div style="width:160px;height:75px;margin:0 auto;"></div><div style="padding:30px;text-align:center;">错误码'+parseInt(data.info[0])+'您的appkey错误</div></div></li>');
		    				break;
		    			default:
		    				$('#msgArea').html('<li><div class="errorMsg" style="width:100%;height:100%"><div style="width:160px;height:75px;margin:0 auto;"></div><div style="padding:30px;text-align:center;">错误码'+parseInt(data.info[0])+'系统繁忙，请稍后再试</div></div></li>');
		    				break;
		    			}
		    		}
		    	}	
			},
			error: function () {
				//console.log("get topic tweet list error");
			}
		});
	},
	showLoginWin:function(code){
		wall.loginCode = code;
		var w = 700,
			h = 460 ,
			t = (screen.height - h)/2,
			l = (screen.width - w)/2,
			p = {
				"appid":46000101,
				"daid":6,
				"style":11,
				"target":"self",
				"low_login":1,
				"hide_title_bar":1,
				"hide_close_icon":1,
				"self_regurl":"http://reg.t.qq.com/index.php?pref=readwall",
				"hln_logo":"http://mat1.gtimg.com/app/opent/images/websites/space.gif",
				"s_url":"http://wall.v.t.qq.com/index.php?c=wall&a=jump&token="+encodeURIComponent(wall.getToken())
			},
			s = "width="+w+",height="+h+",top="+t+",left="+l+",toolbar=no,menubar=no,scrolbars=no,resizeable=no,status=no";
		window.open('http://ui.ptlogin2.qq.com/cgi-bin/login?' + $.param(p) ,'_blank',s);
	},
	loginCallBack:function(i){
		if (i === 1){
			$("#postForm").trigger("submit");
		}else if(i === 2){
			$("#followbtn").trigger("click");
		}
	},
	setLoginInfo:function(u){
		if (u.name){
			window._hadlogin = 1;
		}else{
			window._hadlogin = -1;
		}
		wall.loginCallBack(wall.loginCode);
	},
	weibo:function() {
		return {
			"getTypeStr": function(t) {
				if (t === 2) {
					return '<span class="weibo_type">转播：</span>';
				} else if (t === 4) {
					return '对话：';
				} else {
					return '：';
				}
			},
			"getWeiboText": function(t, s) {
				if (s){
					if (t === 3) {
						return '<span class="weibo_text weibo_text_del">内容已被作者删除</span>';
					} else {
						var es = wall.emos;
						s = s.replace(/&#\d+;/g, "");
				        for (var i = 0,k=es.length,e=es[0]; i < k; i++,e=es[i]) {
				            if (s.indexOf("/" + e) > -1) {
				                s = s.replace(new RegExp("\/" + e, "gi"), "<img src=\"http://mat1.gtimg.com/www/mb/images/face/" + i + ".gif\" title=\"" + e + "\" class=\"weibo_emotion\"/>");
				            }
				        }
						
						s = s.replace(/#([^#]{1,20})#/g, function(){var t = arguments[1],et = encodeURIComponent(t);return "<a href=\"http://t.qq.com/k/"+et+"?pref=internal\" target=\"_blank\">#"+t+"#</a>"});
						s = s.replace(/@([a-zA-Z][a-zA-Z0-9\-_]*)?/g,
				        function($1) {
				            var n = arguments[1];
				            if (wall.userlist[n] && wall.userlist[n] != "") {
				                return "<a href=\"http://t.qq.com/"+n+"?pref=internal\" title=\"" + n + "\" target=\"_blank\" class=\"weibo_user\">" + wall.userlist[n] + "</a>";
				            } else {
				                for (var i in wall.userlist) {
				                    var tn = new RegExp("^" + n + "$", "i").exec(i);
				                    if (tn && wall.userlist[tn]) {
				                        return "<a href=\"http://t.qq.com/"+tn+"?pref=internal\" title=\"" + tn + "\" target=\"_blank\" class=\"weibo_user\">" + wall.userlist[tn] + "</a>";
				                    }
				                }
				                return $1;
				            }
				        });
						
						return '<span class="weibo_text">'+ s +'</span>';
					}
				}else{
					return "";
				}
			},
			"getVipIconStr": function(t) {
				if (t) {
					return '<img src="http://mat1.gtimg.com/app/vt/images/space.gif" align="absmiddle" class="vip" />';
				} else {
					return '';
				}
			},
			"getTime":function(t){
				t = new Date(t*1000);
		        var c =new Date(),
		        s = "",
		        td = [t.getFullYear(),t.getMonth(),t.getDate()],
		        cd = [c.getFullYear(),c.getMonth(),c.getDate()],
		        df = [cd[0]-td[0],cd[1]-td[1],cd[2]-td[2]],
		        dt = df[0]?[td[0],"年",td[1]+1,"月",td[2],"日"].join(""):[td[1]+1,"月",td[2],"日"].join(""),
		        ft = function(t){return ("00"+t).slice(-2);}
		        ;
		        dt = ["今天","昨天","前天"][(df[0]&&1)*100 +(df[1]&&1)*10 + df[2]] || dt;
		        dt += " "+ft(t.getHours())+":"+ft(t.getMinutes());
		        return dt;
			},
			"getImgs":function(t,id){
				var s="";
				if (t){
					if (window._showImg === 0){
						s = "<br/><a href=\"http://t.qq.com/p/t/"+id+"\" class=\"weibo_img_icon\" target=\"_blank\"></a>"
					}else{
						s = "<br/>"+t.join(" ").replace(/([\S]+)/g,"<a href=\"http://t.qq.com/p/t/"+id+"\" class=\"weibo_img\" target=\"_blank\"><img src=\"$1/120\"/></a>");
					}
				}
				return s;
			},
			"getVideo":function(v,id){
				if (!(v && v.picurl)){
					return "";
				}
				if (/^http:\/\/t\d+.qpic.cn/.test(v.picurl)){
					v.picurl = v.picurl+"/120";
				}
				return v && "<br/><a href=\"http://t.qq.com/p/t/"+id+"?pref=readwall\" class=\"weibo_video\" target=\"_blank\"><img src=\""+v.picurl+"\" onload=\"wall.resizeImg(this,148);\" onerror=\"wall.resetImg(this);\"/><span class=\"weibo_video_icon\"></span></a>" || "";
			}
		};
	},
	"resizeImg":function(img,max){
		if (img.width>max){
			img.width = max;
		}
	},
	"resetImg":function(img){
		img.src="http://mat1.gtimg.com/app/vt/images/read/video_s1.gif";
		this.onerror = null;
	},
	callWithScroller:function(list){
		var tempFn = tmpl(wall.temp),
			sourceFn = tmpl(wall.tempSource),
			o1 = wall.weibo(),
			o2 = wall.weibo(),
			btn = $("#btn_weibo_next");
		
			o1.getSourceStr = function(data){
				if (data){
					o2.data = data;
					return sourceFn(o2);
				}else{
					return "";
				}
			}
			
		for(var i in list){
			try{
				if (list[i].name){
					o1.data = list[i];
					$('#msgArea').append(tempFn(o1));
				}
			}catch(e){
				//console.log(["error in：",i,list[i]]);
			}
		}
		
		if (!btn.is(":visible")){
			btn.removeClass("none");
		}
	},
	callWithNoScroller:function(){
		var _height = wall.area.height(),
			tempFn = tmpl(wall.temp),
			sourceFn = tmpl(wall.tempSource),
			o1 = wall.weibo(),
			o2 = wall.weibo();
		
			var _th = 0;
			o1.getSourceStr = function(data){
				if (data){
					o2.data = data;
					return sourceFn(o2);
				}else{
					return "";
				}
			}
			
			while(_th<_height){
				try{
					o1.data = wall.list.pop();
					$('#msgArea').prepend(tempFn(o1));
					_th += $('#msgArea li:first-child').height();
				}catch(e){
					break;
				}
			}
		window.clearTimeout(wall._time);
		if(wall.list.length === 0){
			wall._time = setTimeout(wall.get,wall.getNextTimer());
		}else{
			wall._time = setTimeout(wall.appOne,2000);
		}
	},
	appOne:function(d){
		var tempFn = tmpl(wall.temp),
			sourceFn = tmpl(wall.tempSource),
			o1 = wall.weibo(), 
			o2 = wall.weibo();
			o1.getSourceStr = function(data){
			if (data){
					o2.data = data;
					return sourceFn(o2);
				}else{
					return "";
				}
			}
			o1.data = d || wall.list.pop();
		if (o1.data){
			$('#msgArea').prepend(tempFn(o1));
			$('#msgArea li:first-child').hide().slideDown(500,function(){
				$(this).fadeIn(500);
				window.clearTimeout(wall._time);
				if (wall.list.length){
					wall._time = setTimeout(wall.appOne,2000);
				}else{
					wall._time = setTimeout(wall.get,wall.getNextTimer());
				}
			});
			$('#msgArea li:last-child').remove();
		}else{
			wall.get();
		}
	},
	resizeImg:function(img,max){
			if (img.width>max){
				img.width = max;
			}
	},
	getToken:function(){
		var _hash = getcookie('__hash__');
		   $('input[name="hash"]').attr("value",_hash);
		   return _hash;
	},
	followUser:function(){
		$("#followbtn").click(function(){
			var t = $(this),data = {"appkey":_appkey,"op":+t.attr("data-status")||0,"hash":wall.getToken(),"name":t.attr("data-name")};
			if (window._hadlogin === 1){
			$.ajax({
				"type":"post",
		 		"dataType":"json",
		 		"url":"?c=wall&a=listen",
		 		"data":data,
		 		"success":function(d){
		 			var ret = +d.ret,
		 			code = d.errcode,
		 			msg = d.msg,
		 			ta = ["收听","取消收听"][data.op],
		 			fn = function(d){
		 				if (data.op === 0){
		 					t.addClass("followbtn_gray").attr("title","取消收听").attr("data-status",1);
		 				}else{
		 					t.removeClass("followbtn_gray").attr("title","收听").attr("data-status",0);
		 				}
		 				if (wall.isInFrame() && !wall.isTencent()){
							alert("成功"+ta+"腾讯微博帐号"+data.name+"！");
						}
		 			};
		 			if (ret === 0){
		 				fn();
		 			}else if(ret === 2 && code ===1){
		 				alert(ta+"失败，次数超过限制！");
		 			}else if(ret === -2 && code === 1){
		 				wall.showLoginWin(2);
		 			}else if(ret === 3 && (Math.abs(code) === 3154 || Math.abs(code) === 3183)){
		 				wall.showLoginWin(2);
		 			}else if(ret === 4 && code === 80024){
		 				alert("不能"+ta+"自己！");
		 			}else{
		 				alert(ta+"失败，"+msg);
		 			}
		 		},
		 		"error":function(){
		 			alert("网络连接失败");
		 		}
			});
			}else if(window._hadlogin === 0){
				wall.showLoginWin(2);
			}else if(window._hadlogin === -1){
				if (window.confirm("您还未开通微博，是否现在开通？")){
	        		window.open("http://reg.t.qq.com/invite/?pref=wall.v.t.qq.com");
	        	};
			}
		});
	},
	showErr:function(s,r,b){
		//r:0 灰色提示 1:红色报警提示
		$('#eMsg').html(s).removeAttr("class").addClass(["c_gray","c_orange","loading"][r]+" "+["f26","f12"][b||0]);
	},
	setFastKey:function(){
		$("body").keydown(function(event){
			if (event.ctrlKey){
				if (event.keyCode === 13){
					$("#postForm").submit();
				}
			}
		});
	},
	weiboContent:{
		smartLen:function(str){
			str = str.replace(new RegExp("((news|telnet|nttp|file|http|ftp|https)://){1}(([-A-Za-z0-9]+(\\.[-A-Za-z0-9]+)*(\\.[-A-Za-z]{2,5}))|([0-9]{1,3}(\\.[0-9]{1,3}){3}))(:[0-9]*)?(/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*)*","gi"),new Array(11).join("aa"));
			return Math.ceil(($.trim(str.replace(/[^\u0000-\u00ff]/g,"aa")).length)/2);
		},
		getContentLen:function(){
			var arr = [$('#content').val()],str = "";
			if (window._url){
				arr.push("( 来自"+window._url+" )");
			}
			str = arr.join(" ");
			var sl = wall.weiboContent.smartLen(str);
			return 140 - sl;
		},
		smartCut:function(str,maxlen){
			var len = maxlen,str2="",arr =[str];
			if (window._url){
				arr.push("( 来自"+window._url+" )");
			}
			if( wall.weiboContent.smartLen(arr.join(" ")) < maxlen ){
		       return str;
			}else{
				for( var i=str.length;i>0;i--){
					arr[0] = str.substr(0,i);
				    if( wall.weiboContent.smartLen( arr.join(" ") ) < maxlen ){
					    return arr[0];
					}
				}
				return str;
			}
		}
	}
}

var act = {
	showHead: function(d){
		if(!d){
			return 'http://mat1.gtimg.com/www/mb/images/head_50.jpg';	
		}else{
			return d+'/50';
		} 
	},
	getTime : function(t){
		var nowDate = new Date(t*1000);
        var _format = function(n) { return n = n < 10 ? '0' + n : n; }
        var _lformat = function(n) { return n = (n > 60 && n < 1900) ? n + 1900 : n; }
		var diff = parseInt(nowDate.getTime()/1000) - parseInt(t);
		if(diff < 60*24*30*12){
			return (nowDate.getMonth() + 1)+'月'+_format(nowDate.getDate())+'日' + ' ' +_format(nowDate.getHours())+':'+_format(nowDate.getMinutes());
		}else{
			return _lformat(nowDate.getYear())+'年'+(nowDate.getMonth() + 1)+'月'+_format(nowDate.getDate())+'日' + ' ' +_format(nowDate.getHours())+':'+_format(nowDate.getMinutes());
		}
	}			  
}

function getReturn(d){
	var ret = +(d && d.ret),code = +(d && d.errcode),msg = d && d.msg,info = d && d.data && d.data.info && d.data.info[0];
	$("#post").removeClass("disabled");
	
	if (d){
		if (ret === 0){
			wall.appOne(info);
			wall.showErr('发表成功',0,1);
			$("#content").val(["#",decodeURIComponent(_htname),"# "].join(""));
			if ($("#msgArea").find(".errorMsg").size()){
				$("#msgArea").find(".errorMsg").remove();
			}
			$("#htArea")[0].scrollTop = 0;
			if (wall.isInFrame() && !wall.isTencent()){
				alert("成功发表到腾讯微博！");
			}
		}else if(ret === -1 && code === 1){
			wall.showErr('发表失败，来源出错',1,1);
		}else if(ret === -2 && code === 1){
			wall.showErr('您还未登录，<a href="javascript:;" onclick="wall.showLoginWin(1);">请先登录</a>！',1,1);
			wall.showLoginWin(1);
		}else if(ret === 3 && (Math.abs(code) === 3154 || Math.abs(code) === 3183)){
			wall.showErr('登录态失效，请重新登录！',1,1);
			wall.showLoginWin(1);
		}else if(ret === 4 && code === 14){
			wall.showErr('需要<a href="http://t.qq.com/reg/authenticationActivity.php" target="_blank">领取天下无双勋章！</a>才能发表',1,1);
		}else{
			wall.showErr('发表失败',1,1);
		}
	}
	
	if ($("#selectFile").val()){
		if (ret === 0){
			$("#fileStatus").removeAttr("class").addClass("success").html("上传成功");
			$("#selectFile").val("");
			$("#selectFile").replaceWith($("#selectFile").clone(true)); //清空input为file时的值
		}else{
			$("#fileStatus").removeAttr("class").addClass("error").html("上传失败");
		}
	}
}

function getcookie(name) {
    var cookie_start = document.cookie.indexOf(name);
    var cookie_end = document.cookie.indexOf(";", cookie_start);
    return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
} 
wall.init(); /*
window.onload = function(){
	var t = $("#content")[0];
	if (t){
		if (document.selection){
				t.focus();
			var sel = document.selection.createRange();
				sel.move('character',t.value.length);
				sel.select();
		}
	}
}  */
/*  |xGv00|4e574ff094384556b2f2f597b1af4907 */